using System;
using System.Collections.Generic;
using ExamServer.Service;
using Microsoft.AspNetCore.Mvc;

namespace ExamServer.Controllers
{
    [ApiController]
    [Route("[controller]")]
    //图像识别
    public class ImageController : ControllerBase
    {
       

        [HttpPost]
        public IActionResult Get()
        {
            string file = HttpContext.Request.Form["file"].ToString();
            //调用百度API 获取Token
            Baidu.TOKEN = Baidu.getAccessToken();
            //调用百度API 通用图像识别
           // string path = AppDomain.CurrentDomain.BaseDirectory + "\\酸菜鱼.jpg";
            //string result = Baidu.advancedGeneral(path); //通用识别
            //string result = Baidu.ingredient(path); //果蔬识别
            string result = Baidu.dish(file);//菜品识别
            JsonResult json = new JsonResult(result);

            //JsonResult json = new JsonResult("");
            return json;
        }
    }
}